using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;


namespace AutoLogOffInWPF
{

    public partial class LoginView : System.Windows.Window
    {
        Window1 mainWindow = null;
        public LoginView()
        {
            InitializeComponent();
            btnLogin.Click += new RoutedEventHandler(btnLogin_Click);
            btnCancel.Click += new RoutedEventHandler(btnCancel_Click);
            this.Closed += new EventHandler(LoginView_Closed);
        }

        void LoginView_Closed(object sender, EventArgs e)
        {
            Application.Current.Shutdown();
        }
        void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (txtUserName.Text == "A" && txtPassword.Password == "A")
            {
                this.Hide();
                if (mainWindow == null)
                {
                    mainWindow = new Window1();
                    mainWindow.Show();
                }
                else
                    mainWindow.Show();

            }
            else
            {
                MessageBox.Show("Wrong UserName/PassWord");
            }

        }


    }
}